package cn.kgc.service.impl;

import cn.kgc.dao.SalaryDao;
import cn.kgc.pojo.Salary;
import cn.kgc.pojo.SalaryReason;
import cn.kgc.service.SalartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author: 海宁
 * @date: 2022/1/24
 * @description:
 */
@Service
public class SalaryServiceImpl implements SalartService {
    @Resource
    private SalaryDao salaryDao;
    @Override
    public List<Salary> selsal(String payStandardCode, Integer checkState, String startDate, String endDate) {
        String s = null;
        if(checkState==0){
            s = null;
        }else if(checkState==1){
            s="起草";
        }else if(checkState==2){
            s="审核通过";
        }else if(checkState==3){
            s="审核中";
        }else if(checkState==4){
            s="驳回";
        }else if(checkState==5){
            s="删除";
        }
        List<Salary> list = salaryDao.selsal( payStandardCode, s,startDate,endDate);
        return list;
    }

    @Override
    public Salary selsalbyid(Integer id) {
        Salary salary = salaryDao.selsalbyid(id);
        return salary;
    }

    @Override
    public Boolean delsal(Integer id) {
        if(salaryDao.delsal(id)>0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean addsal(Salary salary) {
        if(salaryDao.addsal(salary)>0){
            return true;
        }
        return false;
    }

    @Override
    public int sellast() {
        int i = salaryDao.sellast();
        return i;
    }

    @Override
    public Boolean update(Salary salary) {
        if(salaryDao.updsal(salary)>0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean addreason(SalaryReason sr) {
        if(salaryDao.addreason(sr)>0){
            return true;
        }
        return false;
    }

    @Override
    public SalaryReason selSr(int sid) {

         SalaryReason sr= salaryDao.selSr(sid);
        return sr;
    }

    @Override
    public Boolean updreason(SalaryReason sr) {
        if(salaryDao.updreason(sr)>0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean delall() {
        if(salaryDao.delall()>0){
            return true;
        }
        return false;
    }


}
